import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

class ToastUtils{

  static Widget init(msg,Widget icon){
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 8),
      decoration: BoxDecoration(
        color: Colors.black,
        borderRadius: BorderRadius.circular(16),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          icon,
          SizedBox(
            width: 8,
          ),
          Text(
            msg,
            style: const TextStyle(color: Colors.white),
          )
        ],
      ),
    );
  }

  static void success(BuildContext context,String msg){
    FToast fToast = FToast();
    fToast.init(context);
    fToast.showToast(
      child: init(msg,const Icon(Icons.check_circle_outline_rounded,color: Colors.white,)),
      toastDuration: const Duration(seconds: 2)
    );
  }

  static void info(BuildContext context,String msg){
    FToast fToast = FToast();
    fToast.init(context);
    fToast.showToast(
        child: init(msg,const Icon(Icons.info_outline_rounded,color: Colors.white,)),
        toastDuration: const Duration(seconds: 2)
    );
  }

  static void error(BuildContext context,String msg){
    FToast fToast = FToast();
    fToast.init(context);
    fToast.showToast(
        child: init(msg,const Icon(Icons.close_rounded,color: Colors.redAccent,)),
        toastDuration: const Duration(seconds: 2)
    );
  }

}